package com.yonyou.pmclouds.measureindex.service.rmiimpl;

import com.alibaba.dubbo.config.annotation.Service;
import com.yonyou.pmclouds.ApplicationConsts;
import com.yonyou.pmclouds.basecom.bp.processor.AuditInfoInsertMultiProcessor;
import com.yonyou.pmclouds.basecom.bp.template.MultiInsertBpTemplate;
import com.yonyou.pmclouds.basecom.exception.BusinessException;
import com.yonyou.pmclouds.measureindex.entity.MeasureIndexHistoryVO;
import com.yonyou.pmclouds.measureindex.mapper.MeasureIndexHisMapper;
import com.yonyou.pmclouds.measureindex.service.rmiitf.MeasureIndexHisMaintin;
import org.springframework.beans.factory.annotation.Autowired;

@Service(interfaceClass = MeasureIndexHisMaintin.class, version = ApplicationConsts.APPLICATION_VERSION)
public class MeasureIndexHisMaintainImpl implements MeasureIndexHisMaintin {

    @Autowired
    private MeasureIndexHisMapper measureIndexHisMapper;

    @Override
    public MeasureIndexHistoryVO[] insert(MeasureIndexHistoryVO[] measureIndexHistoryVOS) throws BusinessException {
        if (measureIndexHistoryVOS == null || measureIndexHistoryVOS.length <= 0) {
            return null;
        }

        MultiInsertBpTemplate<MeasureIndexHistoryVO> bp = new MultiInsertBpTemplate<>(measureIndexHisMapper);
        bp.addBeforeProcessor(new AuditInfoInsertMultiProcessor<MeasureIndexHistoryVO>());

        //插入反馈记录
        return bp.insert(measureIndexHistoryVOS);
    }

}
